package com.sinry.api.client.interceptors;

import com.sinry.common.log.utils.TraceIdUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * @author linxinlei
 * @project sinry-cloud
 * @description header拦截器
 * @date 2022/6/5
 **/
public class FeignRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        template.header(TraceIdUtil.TRACE_ID, TraceIdUtil.getTraceId());
        // 设置调用方id给下游
        template.header(TraceIdUtil.PARENT_ID, TraceIdUtil.getSpanId());
    }
}
